home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / conqsrc.lha / Conquest / src / commands.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-20  |  16.9 KB  |  888 lines

  1. /* Commands.c: Getting user commands */
  2. #include <stdio.h>
  3. #include "defs.h"
  4. #include "structs.h"
  5. #include "vars.h"
  6. #include "protos.h"
  7.  
  8. void blast_planet()
  9. {
  10.   int tf_num, planet_num;
  11.   tplanet *pplanet; 
  12.   int factors,starnum; 
  13.   char iline[81]; 
  14.   int ind = 1, amount; 
  15.  
  16.   printf("last");
  17.   clear_left();
  18.   point(1,19);
  19.   printf("Firing TF:");
  20.  
  21.   tf_num = get_char() - 'A' + 1;
  22.  
  23.   if ((tf_num < 1) || (tf_num > 26))
  24.   {
  25.     error(" !Illegal tf");
  26.     return;
  27.   }
  28.  
  29.   if (tf[player][tf_num].dest == 0) 
  30.   {
  31.     error(" !Nonexistent tf");
  32.     return;
  33.   }
  34.   
  35.   if (tf[player][tf_num].eta != 0)
  36.   {
  37.     error(" !Tf is not in normal space   ");
  38.     return;
  39.   }
  40.   
  41.   if (tf[player][tf_num].blasting)
  42.   {
  43.     error(" !Tf is already blasting     ");
  44.     return;
  45.   }
  46.  
  47.   if ((tf[player][tf_num].b == 0) && (tf[player][tf_num].c == 0)) 
  48.   {
  49.     error(" !Tf has no warships         ");
  50.     return;
  51.   }
  52.  
  53.   starnum = tf[player][tf_num].dest;
  54.   pplanet = stars[starnum].first_planet;
  55.   
  56.   if (pplanet == NULL)
  57.   {
  58.     error(" !No planets at star %c       ", starnum + 'A' - 1);
  59.     return;
  60.   }
  61.  
  62.   point(1,20);
  63.   printf("Target colony ");
  64.  
  65.   if (pplanet->next== nil) /* Only planet at star */
  66.     printf("%2d",pplanet->number);
  67.   else
  68.   {
  69.     printf(":");
  70.     planet_num = get_char() - '0';
  71.     
  72.     for (;(pplanet->number != planet_num) && (pplanet->next); 
  73.      pplanet = pplanet->next);
  74.  
  75.     if (pplanet->number != planet_num) 
  76.     {
  77.       error(" !No such planet at this star ");
  78.       return;
  79.     }
  80.   }
  81.   
  82.   if (pplanet->team == ENEMY)
  83.   {
  84.     error(" !Conquer it first!");
  85.     return;
  86.   }
  87.   
  88.   if ((pplanet->team == player) && (!pplanet->conquered)) 
  89.   {
  90.     error(" !That is a human colony!!    ");
  91.     return;
  92.   }
  93.   
  94.   factors = weapons[player] 
  95.     * ((tf[player][tf_num].c * c_guns) +
  96.        (tf[player][tf_num].b * b_guns));
  97.   
  98.   point(1,21);
  99.   printf("Units (max %3d) :", factors/4);
  100.   point(18,21);
  101.   get_line(iline);
  102.   get_token(iline,&amount);
  103.   
  104.   if (amount < 0)
  105.     factors = 0;
  106.   else
  107.     if (amount > 0)
  108.       factors = min(factors, amount * 4);
  109.   
  110.   tf[player][tf_num].blasting = true;
  111.   point(1,22);
  112.   printf("Blasting %3d units", factors/4);
  113.  
  114.   blast(pplanet,factors);
  115.  
  116.   point(1,23);
  117.   left_line[23] = true;
  118.   putchar(pplanet->pstar+'A'-1);
  119.  
  120.   pplanet->psee_capacity = pplanet->capacity;
  121.  
  122.   if (((y_cursor > 21) && (x_cursor >= 50)) || (y_cursor > 24))
  123.   {
  124.     pause();
  125.     clear_field();
  126.     point(50,1);
  127.   }
  128.  
  129.   printf("%d:%2d                         ", 
  130.      pplanet->number, pplanet->psee_capacity);
  131.   point(x_cursor + 5, y_cursor);
  132.   x_cursor = x_cursor - 5;  
  133.   if (pplanet->psee_capacity == 0)
  134.     printf(" Decimated");
  135.   else if ((pplanet->team == none))
  136.     printf(" No colony");
  137.   else if (pplanet->team == player) /* This must be a conquered planet! */
  138.   {
  139.     printf("(%2d,/%3d)", pplanet->inhabitants, pplanet->iu);
  140.     printf("Con");
  141.     /*    else
  142.       printf("   ");
  143.     if ( pplanet->mb!=0 )
  144.       printf("%2dmb", pplanet->mb);
  145.     else
  146.       printf("    ");
  147.     if ( pplanet->amb!=0 )
  148.       printf("%2damb", pplanet->amb);*/
  149.   } /* Impossible that we have blasted at an enemy */
  150.   /* And besides, this should be a generic routine */
  151.   /*
  152.   else if ((pplanet->team==ENEMY) && see)
  153.   {
  154.     printf("*EN*");
  155.     if ( see && pplanet->conquered )
  156.     {
  157.       printf("Conquered");
  158.     } 
  159.     else
  160.       printf("   ");
  161.     if ( pplanet->under_attack )
  162.     {
  163.       if ( pplanet->mb != 0 )
  164.         printf("%2dmb", pplanet->mb);
  165.       else
  166.         printf("    ");
  167.       if ( pplanet->amb != 0 )
  168.         printf("%2damb", pplanet->amb);
  169.     }
  170.       }
  171.       point(x_cursor,y_cursor + 1);
  172.   */      
  173. }
  174.  
  175. void inputplayer()
  176. {
  177.   char key; 
  178.   boolean fin;
  179.  
  180.   point(33,20);
  181.   printf("* Movement *    ");
  182.  
  183.   fin=false;
  184.   do
  185.   {
  186.     point(1,18);
  187.     printf("?                             ");
  188.     point(2,18);
  189.     key = get_char();
  190.  
  191.     switch (key)
  192.     {
  193.      case 'M': 
  194.       printmap();
  195.       break;
  196.      case 'B': 
  197.       blast_planet();
  198.       break;
  199.      case 'G': 
  200.      case ' ': 
  201.       fin=true;
  202.       break;
  203.      case 'H': 
  204.       help(1);
  205.       break;
  206.      case 'L': 
  207.       land();
  208.       break;
  209.      case 'D': 
  210.       send_tf();
  211.       break;
  212.      case 'S': 
  213.       starsum();
  214.       break;
  215.      case 'N': 
  216.       make_tf();
  217.       break;
  218.      case 'J': 
  219.       join_tf();
  220.       break;
  221.      case 'C': 
  222.       print_col();
  223.       break;
  224.      case 'R': 
  225.       ressum();
  226.       break;
  227.      case 'Q':
  228.       fin = true;
  229.       quit();
  230.       break;
  231.      case '?':
  232.       break;
  233.      case 'T': 
  234.       tfsum();
  235.       break;
  236.      case 'E':
  237.       /* Info about enemy - for debugging purposes only! */
  238. #ifdef DEBUG
  239.       point(50,1);
  240.       clear_field();
  241.       point(50,1);
  242.       printf("Enemy status:");
  243.       point(50,2);
  244.       printf("V: %d, R: %d, W: %d, Next: %c", vel[ENEMY], range[ENEMY], weapons[ENEMY], en_research);
  245.       point(50,3);
  246.       printf("C:");
  247.       for (key = 1; key <= MAX_NUM_STARS; key++)
  248.     if (col_stars[key][ENEMY])
  249.       printf("%c", key + 'A' - 1);
  250.       point(50,4);
  251.       printf("F:");
  252.       for (key = 1; key <= MAX_NUM_STARS; key++)
  253.     if (tf_stars[key][ENEMY])
  254.       printf("%c", key + 'A' - 1);
  255.       printf(" ");
  256.       for (key = 1; key <= MAX_FLEETS; key++)
  257.     if ((tf[ENEMY][key].dest != 0) && (tf[ENEMY][key].eta > 0))
  258.       printf("%c%d", tf[ENEMY][key].dest+'A'-1, tf[ENEMY][key].eta);
  259.       break;
  260. #endif
  261.      default:
  262.       error("  !illegal command");
  263.     }  /*switch */
  264.   } 
  265.   while (!fin);
  266. }
  267.  
  268. void land()
  269. {
  270.   char tfc,planc; 
  271.   int x,y,room_left,tfnum, transports,planet_num;
  272.   int starnum; 
  273.   char iline[81]; 
  274.   struct stplanet *pplanet;
  275.  
  276.   printf("and tf:");
  277.   tfc = get_char();
  278.   clear_left();
  279.   tfnum = tfc-'A'+1;
  280.  
  281.   if ((tfnum<1) || (tfnum>26))
  282.   {
  283.     error("  !illegal tf");
  284.     return;
  285.   }
  286.  
  287.   if ((tf[player][tfnum].dest == 0))
  288.   {
  289.     error("  !nonexistent tf");
  290.     return;
  291.   }
  292.  
  293.   if ((tf[player][tfnum].eta != 0))
  294.   {
  295.     error("  !tf is not in normal space  ");
  296.     return;
  297.   }
  298.  
  299.   starnum= tf[player][tfnum].dest;
  300.   pplanet= stars[starnum].first_planet;
  301.  
  302.   if (pplanet == NULL)
  303.   {
  304.     error("  !no planets at this star    ");
  305.     return;
  306.   }
  307.   
  308.   if (tf_stars[starnum][ENEMY] > 0) 
  309.   {
  310.     error("  !enemy ships present");
  311.     return;
  312.   }
  313.  
  314.   /* This should be put in a procedure soon */
  315.   point(11,18);
  316.   printf(" planet ");
  317.   if (pplanet->next == NULL) 
  318.   {
  319.     planet_num = pplanet->number;
  320.     printf("%d", planet_num);
  321.   } 
  322.   else 
  323.   {
  324.     printf(":");
  325.     planc = get_char();
  326.     planet_num = planc-'0';
  327.  
  328.     for (;(pplanet) && (pplanet->number != planet_num); pplanet = pplanet->next);
  329.     
  330.     if (!pplanet)
  331.     {
  332.       error(" !Not a habitable planet ");
  333.       return;
  334.     }
  335.   }
  336.   
  337.   if ((pplanet->team == ENEMY) || 
  338.       ((pplanet->team == player) && (pplanet->conquered)))
  339.   {
  340.     error("  !Enemy infested planet  !!  ");
  341.     return;
  342.   }
  343.   
  344.   /* get the number of transports*/
  345.   room_left = pplanet->capacity - pplanet->inhabitants;
  346.   
  347.   point(1,19);
  348.   printf(" transports:");
  349.   get_line(iline);
  350.   get_token(iline,&transports);
  351.  
  352.   if (transports == 0) transports = tf[player][tfnum].t;
  353.   
  354.   if (transports < 1)
  355.   {
  356.     error("  !illegal transports");
  357.     return;
  358.   }
  359.  
  360.   if (transports > tf[player][tfnum].t) 
  361.   {
  362.     error("  !only %2d transports in tf", tf[player][tfnum].t);
  363.     return;
  364.   }
  365.   
  366.   if (transports > room_left)
  367.   {
  368.     error("  !only room for %2d transports", room_left);
  369.     return;
  370.   }
  371.   
  372.   pplanet->team = player;
  373.   if (pplanet->inhabitants == 0)
  374.     col_stars[starnum][player]++;
  375.   pplanet->inhabitants=pplanet->inhabitants+transports;
  376.   pplanet->iu=pplanet->iu + transports;
  377.   tf[player][tfnum].t=tf[player][tfnum].t-transports;
  378.  
  379.   x=tf[player][tfnum].x; 
  380.   y=tf[player][tfnum].y;
  381.   if (board[x][y].enemy == ' ')
  382.   {
  383.     board[x][y].enemy = '@';
  384.     update_board(x,y,left);
  385.   }
  386.   point(1,20);
  387.   putchar(starnum+'A'-1);
  388.   
  389.   if (((y_cursor > 21) && (x_cursor >= 50)) || (y_cursor > 24))
  390.   {
  391.     pause();
  392.     clear_field();
  393.     point(50,1);
  394.   }
  395.  
  396.   printf("%d:%2d                         ",
  397.      pplanet->number, pplanet->psee_capacity);
  398.  
  399.   point(x_cursor + 5, y_cursor);
  400.   x_cursor = x_cursor - 5;
  401.  
  402.   printf("(%2d,/%3d)   ", pplanet->inhabitants, pplanet->iu);
  403.   
  404.   if (pplanet->mb != 0)
  405.     printf("%2dmb", pplanet->mb);
  406.   else
  407.     printf("    ");
  408.  
  409.   if (pplanet->amb!=0)
  410.       printf("%2damb", pplanet->amb);
  411.   
  412.   point(x_cursor,y_cursor + 1);
  413.   
  414.   zero_tf(player,tfnum);
  415.   print_tf(tfnum);
  416. }
  417.  
  418. void quit()
  419. {
  420.   clear_screen();
  421.   printf("Quit game....[verify]\n");
  422.  
  423.   if (get_char() != 'Y')
  424.     printmap();
  425.   else 
  426.     game_over = true;
  427. }
  428.  
  429. void send_tf()
  430. {
  431.   char tf_move;
  432.   int tf_num;
  433.   
  434.   printf("estination tf:");
  435.  
  436.   tf_move = get_char();
  437.   clear_left();
  438.   point(1,19);
  439.   tf_num = tf_move-'A'+1;
  440.  
  441.   if ((tf_num<1) || (tf_num>26))
  442.   { 
  443.     error(" !illegal tf");
  444.     return;
  445.   } 
  446.   
  447.   if (tf[player][tf_num].dest == 0)
  448.   { 
  449.     error(" !nonexistent tf");
  450.     return;
  451.   } 
  452.  
  453.   if ((tf[player][tf_num].eta != 0) &&
  454.       ((tf[player][tf_num].eta != tf[player][tf_num].origeta) ||
  455.        (tf[player][tf_num].withdrew))) 
  456.   { 
  457.     error(" !Tf is not in normal space  ");
  458.     return;
  459.   } 
  460.   
  461.   if (tf[player][tf_num].blasting) 
  462.   { 
  463.     error(" !Tf is blasting a planet");
  464.     return;
  465.   } 
  466.  
  467.   tf[player][tf_num].withdrew = false;
  468.   set_des(tf_num);
  469. }
  470.  
  471. void inv_player(int x, int y, struct stplanet *planet)
  472. {
  473.   boolean printtf; 
  474.   char iline[81]; 
  475.   char key;
  476.   int cost,amount,ind = 1,new_tf,balance;
  477.   int trash1, trash2;
  478.   
  479.   new_tf = get_tf(player,planet->pstar);
  480.   tf_stars[planet->pstar][player]++;
  481.   printtf = false;
  482.  
  483.   balance=planet->iu;
  484.  
  485.   clear_left();
  486.   point(1,19);
  487.   putchar(planet->pstar+'A'-1);
  488.   
  489.   printf("%d:%2d                         ", planet->number, planet->psee_capacity);
  490.   point(x_cursor + 5, y_cursor);
  491.   x_cursor = x_cursor - 5;
  492.   printf("(%2d,/%3d)", planet->inhabitants, planet->iu);
  493.  
  494.   if (planet->conquered)
  495.     printf("Con");
  496.   else
  497.     printf("   ");
  498.  
  499.   if (planet->mb != 0)
  500.     printf("%2dmb", planet->mb);
  501.   else
  502.     printf("    ");
  503.   if (planet->amb != 0)
  504.     printf("%2damb", planet->amb);
  505.  
  506.   point(x_cursor,y_cursor + 1);
  507.   
  508.   do 
  509.   {
  510.     point(1,18);
  511.     printf("%3d?                          ", balance);
  512.  
  513.     point(5,18);
  514.     get_line(iline);
  515.  
  516.     do 
  517.     {
  518.       cost = 0;
  519.       
  520.       key = get_token(iline,&amount);
  521.       switch (key)
  522.       {
  523.        case 'A': 
  524.  
  525.     if (planet->inhabitants == 0) 
  526.     {
  527.       error("  !abandoned planet");
  528.       break;
  529.     } 
  530.     
  531.     if (planet->conquered)
  532.     {
  533.       error(" !No amb  on conquered colony ");
  534.       break;
  535.     }
  536.  
  537.     cost = amount*amb_cost;
  538.     if (cost < amount) amount = cost = 0;
  539.     if (cost <= balance)
  540.       planet->amb=planet->amb+amount;
  541.     break;
  542.  
  543.        case 'B': 
  544.     cost = amount*b_cost;
  545.     if (cost < amount) amount = cost = 0;
  546.     if (cost <= balance)
  547.     {
  548.       tf[player][new_tf].b=tf[player][new_tf].b + amount;
  549.       printtf = true;
  550.     }
  551.     break;
  552.        case 'C': 
  553.     cost = amount*c_cost;
  554.     if (cost < amount) amount = cost = 0;
  555.     if (cost <= balance)
  556.     {
  557.       tf[player][new_tf].c=tf[player][new_tf].c + amount;
  558.       printtf = true;
  559.     }
  560.     break;
  561.        case 'H': 
  562.     help(4);
  563.     break;
  564.        case 'M': 
  565.     if (planet->inhabitants == 0)
  566.     {
  567.       error("  !abandoned planet");
  568.       break;
  569.     } 
  570.     if (planet->conquered)
  571.     {
  572.       error(" !No Mb  on conquered colony  ");
  573.       break;
  574.     } 
  575.  
  576.     cost=amount * mb_cost;
  577.     if (cost < amount) amount = cost = 0;
  578.     if (cost <= balance)
  579.       planet->mb = planet->mb+amount;
  580.     break;
  581.        case 'S': 
  582.     cost = amount*s_cost;
  583.     if (cost < amount) amount = cost = 0;
  584.     if (cost <= balance)
  585.     {
  586.       tf[player][new_tf].s=tf[player][new_tf].s + amount;
  587.       printtf = true;
  588.     }
  589.     break;
  590.        case 'T': 
  591.     if (planet->conquered)
  592.     {
  593.       error( "!No transports on conqered col");
  594.       break;
  595.     } 
  596.  
  597.     cost = amount;
  598.     if (cost <= balance)
  599.     {
  600.       if (cost > planet->inhabitants)
  601.       {
  602.         error(" ! Not enough people for ( trans");
  603.         cost=0;
  604.         break;
  605.       } 
  606.  
  607.       tf[player][new_tf].t = tf[player][new_tf].t+amount;
  608.  
  609.       planet->inhabitants = planet->inhabitants-amount;
  610.  
  611.       trash1 = planet->iu - amount;
  612.       trash2 = planet->inhabitants * iu_ratio;
  613.       planet->iu = min(trash1, trash2);
  614.  
  615.       printtf = true;
  616.       
  617.       if (planet->inhabitants == 0)
  618.       {
  619.         col_stars[planet->pstar][player]--;
  620.         if (col_stars[planet->pstar][player] == 0)
  621.         {
  622.           board[x][y].enemy = ' ';
  623.           update_board(x,y,left);
  624.         }
  625.  
  626.         planet->team=none;
  627.         planet->amb=0; 
  628.         planet->mb=0; 
  629.         planet->iu=0;
  630.       }
  631.     }
  632.     break;
  633.        case 'I': 
  634.     if ((amount+planet->iu) > (planet->inhabitants*iu_ratio))
  635.     {
  636.       error(" !Can't support that many iu's");
  637.       break;
  638.     } 
  639.  
  640.     cost = i_cost*amount;
  641.     if (cost < amount) amount = cost = 0;
  642.     if (cost <= balance)
  643.       planet->iu=planet->iu+amount;
  644.     break;
  645.        case 'R': 
  646.        case 'V': 
  647.        case 'W':
  648.     cost = amount;
  649.     if (cost <= balance)
  650.     {
  651.       point(1,21);
  652.       research(player,key,amount);
  653.     }
  654.     print_res(key);
  655.     break;
  656.        case '*': /* Invest as much as needed in one item */
  657.     key = get_token(iline, &amount);
  658.     switch (key)
  659.     {
  660.      case 'B':
  661.       amount = max(1, balance/B_COST);
  662.       cost = amount * B_COST;
  663.       if (cost <= balance)
  664.       {
  665.         tf[player][new_tf].b += amount;
  666.         printtf = true;
  667.       }
  668.       break;
  669.      case 'C':
  670.       amount = max(1, balance/C_COST);
  671.       cost = amount * C_COST;
  672.       if (cost <= balance)
  673.       {
  674.         tf[player][new_tf].c += amount;
  675.         printtf = true;
  676.       }
  677.       break;
  678.      case 'S':
  679.       amount = max(1, balance/S_COST);
  680.       cost = amount * S_COST;
  681.       if (cost <= balance)
  682.       {
  683.         tf[player][new_tf].s += amount;
  684.         printtf = true;
  685.       }
  686.       break;
  687.      case 'A':
  688.       if (planet->inhabitants == 0)
  689.       {
  690.         error("  !abandoned planet");
  691.         break;
  692.       } 
  693.       if (planet->conquered)
  694.       {
  695.         error(" !No AMb  on conquered colony  ");
  696.         break;
  697.       } 
  698.       amount = max(1,balance/AMB_COST);
  699.       cost = amount*AMB_COST;
  700.       if (cost <= balance)
  701.         planet->amb = planet->amb+amount;
  702.       break;
  703.      case 'M':
  704.       if (planet->inhabitants == 0)
  705.       {
  706.         error("  !abandoned planet");
  707.         break;
  708.       } 
  709.       if (planet->conquered)
  710.       {
  711.         error(" !No Mb  on conquered colony  ");
  712.         break;
  713.       } 
  714.       amount = max(1,balance/MB_COST);
  715.       cost = amount*MB_COST;
  716.       if (cost <= balance)
  717.         planet->mb = planet->mb+amount;
  718.       break;
  719.      case 'T':
  720.       if (planet->conquered)
  721.       {
  722.         error( "!No transports on conqered col");
  723.         break;
  724.       } 
  725.  
  726.       amount = cost = min(planet->inhabitants, balance);
  727.  
  728.       tf[player][new_tf].t += amount;
  729.       planet->inhabitants = planet->inhabitants-amount;
  730.  
  731.       trash1 = planet->iu - amount;
  732.       trash2 = planet->inhabitants * iu_ratio;
  733.       planet->iu = min(trash1, trash2);
  734.  
  735.       printtf = true;
  736.       
  737.       if (planet->inhabitants == 0)
  738.       {
  739.         col_stars[planet->pstar][player]--;
  740.         if (col_stars[planet->pstar][player] == 0)
  741.         {
  742.           board[x][y].enemy = ' ';
  743.           update_board(x,y,left);
  744.         }
  745.  
  746.         planet->team=none;
  747.         planet->amb=0; 
  748.         planet->mb=0; 
  749.         planet->iu=0;
  750.       }
  751.       break;
  752.      case 'I':
  753.       if (planet->inhabitants*IU_RATIO-planet->iu <= 0)
  754.       {
  755.         error("!Can't support that many IU's.");
  756.         break;
  757.       }
  758.       amount = min(balance/I_COST,planet->inhabitants*IU_RATIO-planet->iu);
  759.       amount = max(1,amount);
  760.       cost = I_COST*amount;
  761.       if (cost <= balance)
  762.         planet->iu=planet->iu+amount;
  763.       break;
  764.      case 'R':
  765.      case 'W':
  766.      case 'V':
  767.       cost = research_limited(PLAYER, key, balance);
  768.       print_res(key);
  769.       break;
  770.      case ' ':
  771.       break;
  772.      default:
  773.       error("Invalid investment field %c", key);
  774.       break;
  775.     }
  776.     break;
  777.        case '+': /* Invest as much as possible in attack */
  778.     amount = balance/B_COST;
  779.     if (amount > 0)
  780.     {
  781.       cost = amount*B_COST;
  782.       tf[player][new_tf].b += amount;
  783.       printtf = true;
  784.     }
  785.     amount = (balance-cost)/C_COST;
  786.     if (amount > 0)
  787.     {
  788.       cost += amount*C_COST;
  789.       tf[player][new_tf].c += amount;
  790.       printtf = true;
  791.     }
  792.     break;
  793.        case '-': /* Invest as much as possible in defence */
  794.     if (planet->inhabitants == 0)
  795.     {
  796.       error("  !abandoned planet");
  797.       break;
  798.     } 
  799.     if (planet->conquered)
  800.     {
  801.       error(" !No defense on conquered colony  ");
  802.       break;
  803.     } 
  804.     amount = balance/AMB_COST;
  805.     if (amount > 0)
  806.     {
  807.       cost = amount*AMB_COST;
  808.       planet->amb = planet->amb+amount;
  809.     }
  810.     amount = (balance-cost)/MB_COST;
  811.     if (amount > 0)
  812.     {
  813.       cost += amount*MB_COST;
  814.       planet->mb = planet->mb+amount;
  815.     }
  816.     break;
  817.        case ' ': 
  818.     break;
  819.        case '>': 
  820.     point(1,18);
  821.     printf(">?     ");
  822.  
  823.     point(3,18);
  824.     key = get_char();
  825.     switch (key)
  826.     {
  827.      case 'M':
  828.       printmap(); 
  829.       break;
  830.      case 'S':
  831.       starsum(); 
  832.       break;
  833.      case 'C':
  834.       print_col(); 
  835.       break;
  836.      case 'R': 
  837.       ressum(); 
  838.       break;
  839.      default:
  840.       error(" !Only M,S,C,R allowed      ");
  841.     }
  842.     break;
  843.        default:
  844.     error(" !Illegal field %c",key);
  845.       }
  846.       if (cost > balance)
  847.       {
  848.     error(" !can't affort %3d%c", amount, key);
  849.       }
  850.       else
  851.     balance = balance - cost;
  852.     } 
  853.     while (key != ' ');
  854.  
  855.     clear_left();
  856.     point(1,19);
  857.     putchar(planet->pstar+'A'-1);
  858.     
  859.     printf("%d:%2d                         ", planet->number, planet->psee_capacity);
  860.     point(x_cursor + 5, y_cursor);
  861.     x_cursor = x_cursor - 5;
  862.     printf("(%2d,/%3d)", planet->inhabitants, planet->iu);
  863.  
  864.     if (planet->conquered)
  865.       printf("Con");
  866.     else
  867.       printf("   ");
  868.  
  869.     if ( planet->mb!=0 )
  870.       printf("%2dmb", planet->mb);
  871.     else
  872.       printf("    ");
  873.     if ( planet->amb!=0 )
  874.       printf("%2damb", planet->amb);
  875.     point(x_cursor,y_cursor + 1);
  876.     
  877.     if (printtf) 
  878.     {
  879.       point(1,20);
  880.       print_tf(new_tf);
  881.     }
  882.   } 
  883.   while (balance > 0);
  884.  
  885.   zero_tf(player,new_tf);
  886.   on_board(x,y);
  887. }
  888.